/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.spider.rule.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.annotations.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author 雨来
* @date 2023-07-07
**/
@Entity
@Data
@Table(name="t_spider_rule")
public class SpiderRule implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`rule_id`")
    @ApiModelProperty(value = "id")
    private Long ruleId;

    @Column(name = "`web_id`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "网站名称")
    private Long webId;

    @Column(name = "`field_name`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "字段名称")
    private String fieldName;

    @Column(name = "`field_code`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "字段编码")
    private String fieldCode;

    @Column(name = "`rule`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "规则")
    private String rule;

//    @Column(name = "`type`")
//    @ApiModelProperty(value = "规则类型")
//    private String type;

    @Column(name = "`deleted_flag`")
    @ApiModelProperty(value = "删除状态")
    private Boolean deletedFlag;

    @Column(name = "`remark`")
    @ApiModelProperty(value = "备注")
    private String remark;

    @Column(name = "`update_time`")
    @UpdateTimestamp
    @ApiModelProperty(value = "更新时间")
    private Timestamp updateTime;

    @Column(name = "`create_time`")
    @CreationTimestamp
    @ApiModelProperty(value = "创建时间")
    private Timestamp createTime;

    public void copy(SpiderRule source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
